# Maintainer: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
# Contributor: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
pkgname=kicad-library
pkgver=8.0.1
pkgrel=0
pkgdesc="Kicad component and footprint libraries"
url="https://kicad.github.io/"
# limited by kicad
arch="noarch !armv7 !armhf !riscv64 !s390x"
license="GPL-3.0-or-later"
makedepends="cmake samurai"
depends="kicad"
subpackages="$pkgname-3d:three_d"
source="
	https://gitlab.com/kicad/libraries/kicad-symbols/-/archive/$pkgver/kicad-symbols-$pkgver.tar.gz
	https://gitlab.com/kicad/libraries/kicad-footprints/-/archive/$pkgver/kicad-footprints-$pkgver.tar.gz
	https://gitlab.com/kicad/libraries/kicad-packages3D/-/archive/$pkgver/kicad-packages3D-$pkgver.tar.gz
	"
options="!check" # package only provides data files, so not tests possible

build() {
	cd "$srcdir"/kicad-symbols-$pkgver
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr
	cmake --build build

	cd "$srcdir"/kicad-footprints-$pkgver
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr
	cmake --build build

	cd "$srcdir"/kicad-packages3D-$pkgver
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install "$srcdir"/kicad-symbols-$pkgver/build
	DESTDIR="$pkgdir" cmake --install "$srcdir"/kicad-footprints-$pkgver/build
}

three_d() {
	DESTDIR="$subpkgdir" cmake --install "$srcdir"/kicad-packages3D-$pkgver/build

	# Remove .step version of 3D models; only .wrl versions are needed
	find "$subpkgdir" -name '*.step' -exec rm {} \;
}

sha512sums="
bbf2d655828c678f2c507c0482d1944d089611d9942e675238b4cd5c44e9641918089d839a5f7eab65574691514308aa07523445149b449e0024f0a36c965031  kicad-symbols-8.0.1.tar.gz
8577aa984855d1f10c37181603f82fd2d545cd475e9bd8fee935f48df314d3f6cb6572630da7176afc8581f1ba4a7b9e33228fd6a79c7bfff71be6f6c01e66ea  kicad-footprints-8.0.1.tar.gz
3077a962cd256b45a8fbecf3f4c3d684e926c7274310d003cf0ee376174da8d0a98ba7ffaf530b90f0bcebfdb773f8751103120876715ceaeba9c295838c6bae  kicad-packages3D-8.0.1.tar.gz
"
